Option Strict Off
Option Explicit On
Public Class ctlSceneTree
    Inherits System.Windows.Forms.UserControl

    Public SelectedNode As String
    Public Event Tree_Click(node As TreeNode)



    Function AddNode(Idx As Short, tvwChild As Short, Nome As String, Nome2 As String) As System.Windows.Forms.TreeNode
        If Len(Nome) = 0 Then
            Nome = GenHandle()
            Nome2 = Nome
        End If
        If IsNumeric(Nome) Then Nome = "K" & Nome
        AddNode = TV.Nodes.Insert(Idx, Nome, Nome2)

    End Function

    Function AddRoot(ByRef Nome As String) As System.Windows.Forms.TreeNode
        AddRoot = TV.Nodes.Add(Nome, Nome)
    End Function


    Sub Clear()
        TV.Nodes.Clear()
    End Sub


    Function NodesCount() As Short
        NodesCount = TV.Nodes.Count
    End Function

 


    Private Sub UserControl_Terminate()
        UT = Nothing
    End Sub

    Private Sub TV_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles TV.AfterCheck
        ' TV.HitTest(New Point(e.Action.ByMouse..x, e.y))
    End Sub

 
    Private Sub TV_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TV.AfterSelect
      
    End Sub

    
    Private Sub TV_Click(sender As Object, e As EventArgs) Handles TV.Click
        Try

            '   TV.HitTest(New Point(e.x, e.y))
            '   SelectedNode = TV.SelectedNode.Text
            '  Dim htest = New TreeViewHitTestInfo = TV.HitTest(New Point(e.x, e.y))
            RaiseEvent Tree_Click(TV.SelectedNode)
        Catch ex As Exception
        End Try
    End Sub
End Class